<template>
  <el-container class="main-layout">
    <!-- 顶部导航栏 -->
    <el-header class="header">
      <div class="header-content">
        <h1 class="header-title">RBAC管理系统</h1>
        <div class="user-info">
          <span>欢迎{{ pinia.UserInfo.UserName }},({{pinia.UserInfo.RoleName   }})登录</span>
          <el-button type="primary" @click="OutLogin">退出登录</el-button>
        </div>
      </div>
    </el-header>
    <el-container>
      <!-- 左侧菜单栏 -->
      <el-aside width="200px" class="aside">
        <div class="menu-wrapper">
          <el-menu default-active="1" class="menu" background-color="#545c64" text-color="#fff"
            active-text-color="#ffd04b" router>
            <el-menu-item index="home">
              <el-icon>
                <House />
              </el-icon>
              <span>首页</span>
            </el-menu-item>
            <el-sub-menu index="2">
              <template #title>
                <el-icon>
                  <Menu />
                </el-icon>
                <span>系统管理</span>
              </template>
              <el-menu-item  index="UserList">
                <el-icon>
                  <User />
                </el-icon>
                <span>用户管理</span>
              </el-menu-item>
              <el-menu-item index="RoleList">
                <el-icon>
                  <UserFilled />
                </el-icon>
                <span>角色管理</span>
              </el-menu-item>
              <el-menu-item index="PermissionList">
                <el-icon>
                  <Lock />
                </el-icon>
                <span>权限管理</span>
              </el-menu-item>
            </el-sub-menu>
          </el-menu>
        </div>
      </el-aside>
      <!-- 主内容 -->
      <el-main class="main-content">
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>
<script setup lang="ts">
import { ElContainer, ElHeader, ElAside, ElMain, ElMenu, ElSubMenu, ElMenuItem, ElIcon, ElButton } from 'element-plus'
import { House, Document, Menu, User, UserFilled, Lock, Setting } from '@element-plus/icons-vue'
import { useCounterStore } from '@/stores/counter'
import { useRouter } from 'vue-router'
const router = useRouter()
const pinia = useCounterStore()
const OutLogin = () => {
  pinia.UserInfo.ToKen = ""
  pinia.UserInfo.RoleName = ""
  localStorage.setItem("IsLogin", "")
  router.push("/")
}
</script>
<style scoped>
/* 主布局样式 */
.main-layout {
  height: 100vh;
  overflow: hidden;
  background-color: #f5f7fa;
}

/* 顶部导航栏样式 */
.header {
  height: 64px;
  background: linear-gradient(135deg, #1890ff 0%, #40a9ff 100%);
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 24px;
}

.header-title {
  margin: 0;
  font-size: 24px;
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title::before {
  content: '';
  width: 32px;
  height: 32px;
  background-color: #ffffff;
  border-radius: 6px;
  display: inline-block;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-info span {
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
}

.user-info .el-button {
  transition: all 0.3s ease;
  border-radius: 6px;
}

.user-info .el-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

/* 左侧菜单栏样式 */
.aside {
  background-color: #ffffff;
  height: calc(100vh - 64px);
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

.menu-wrapper {
  padding-top: 0;
}

.menu {
  border-right: none;
  background-color: #ffffff !important;
  height: 100%;
}

.menu .el-menu-item {
  color: #606266;
  height: 52px;
  line-height: 52px;
  background-color: #ffffff;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  font-size: 14px;
  padding: 0 24px;
}

.menu .el-menu-item:hover {
  color: #1890ff;
  background-color: #e6f7ff;
  border-left-color: #1890ff;
  padding-left: 22px;
}

.menu .el-menu-item.is-active {
  color: #1890ff;
  background-color: #e6f7ff;
  border-left-color: #1890ff;
  font-weight: 500;
}

.menu .el-sub-menu__title {
  color: #606266;
  height: 52px;
  line-height: 52px;
  background-color: #ffffff;
  border-left: 3px solid transparent;
  transition: all 0.3s ease;
  font-size: 14px;
  padding: 0 24px;
}

.menu .el-sub-menu__title:hover {
  color: #1890ff;
  background-color: #e6f7ff;
  border-left-color: #1890ff;
  padding-left: 22px;
}

.menu .el-sub-menu__title.is-active {
  color: #1890ff;
  background-color: #e6f7ff;
  border-left-color: #1890ff;
  font-weight: 500;
}

/* 主内容区域样式 */
.main-content {
  padding: 24px;
  overflow-y: auto;
  background-color: #f5f7fa;
  transition: all 0.3s ease;
}

/* 图标颜色 */
.menu .el-icon {
  color: inherit;
  font-size: 16px;
  margin-right: 12px;
}

/* 滚动条样式 */
.aside::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.aside::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.aside::-webkit-scrollbar-thumb {
  background: #d9d9d9;
  border-radius: 3px;
}

.aside::-webkit-scrollbar-thumb:hover {
  background: #bfbfbf;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .header-content {
    padding: 0 16px;
  }
  
  .header-title {
    font-size: 20px;
  }
  
  .aside {
    width: 200px !important;
  }
  
  .main-content {
    padding: 16px;
  }
}

@media (max-width: 768px) {
  .aside {
    width: 64px !important;
  }
  
  .menu .el-menu-item, 
  .menu .el-sub-menu__title {
    padding: 0;
    text-align: center;
  }
  
  .menu .el-icon {
    margin-right: 0;
  }
  
  .menu .el-menu-item span,
  .menu .el-sub-menu__title span {
    display: none;
  }
}

/* 加载动画效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-content {
  animation: fadeIn 0.3s ease;
}
</style>